#ifndef CArg_h
#define CArg_h

#include <cassert>
#define ASSERT__ME(Must_Be_True, ClassName,CaptionError) assert( (Must_Be_True)&&(ClassName ":" CaptionError) )


class CArg
{
public:
    CArg():mPtr(0l), mInfo(0l){}
    ~CArg(){ delete mPtr; mPtr=0; }

    template<class T> void SetVal(const T& src) { mPtr = new T(src); mSize = sizeof(T);  mInfo = &typeid(T); }

    template<class T> void GetVal(T& dst) 
    {
        ASSERT__ME( typeid(dst)==*mInfo, "CArg::GetVal", "ERROR INVALID_TYPE" );
        if(sizeof(T)==mSize){ dst = *((T*)mPtr); }
    }
private:
    void* mPtr;
    size_t mSize;
    const type_info* mInfo;
};


#endif